package lac.serviceuint.cfg;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAsAttribute;
import com.thoughtworks.xstream.annotations.XStreamImplicit;
import com.thoughtworks.xstream.annotations.XStreamOmitField;
/**
 * 方法
 * @author zhiyi.zhao
 *
 */
@XStreamAlias("method")
public class Method implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 9153806823571972342L;
	
	@XStreamAsAttribute
	private String id;
	@XStreamAsAttribute
	private String name;
	@XStreamAsAttribute
	private String describe;
	@XStreamImplicit(itemFieldName="param")
	private List<MethodParam> params = new ArrayList<MethodParam>();
	@XStreamImplicit(itemFieldName="logic")
	private List<Logic> logics = new ArrayList<Logic>();
	@XStreamAsAttribute
	private Boolean register = false;
	@XStreamAsAttribute
	private String registGroup;
	
	@XStreamOmitField
	private String signatureJavaClass;
	@XStreamOmitField
	private ServiceUnit serviceUnit;
	
	public Method() {
		
	}
	
	public Method(String name) {
		this.name = name;
	}
	
	public Method(String name,String signatureJavaClass) {
		this.name = name;
		this.signatureJavaClass = signatureJavaClass;
	}
	
	public Method(String name,String signatureJavaClass, ServiceUnit serviceUnit) {
		this.name = name;
		this.signatureJavaClass = signatureJavaClass;
		this.serviceUnit = serviceUnit;
	}
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescribe() {
		return describe;
	}
	public void setDescribe(String describe) {
		this.describe = describe;
	}
	public ServiceUnit getServiceUnit() {
		return serviceUnit;
	}
	public void setServiceUnit(ServiceUnit serviceUnit) {
		this.serviceUnit = serviceUnit;
	}
	public List<Logic> getLogics() {
		return logics;
	}
	public void setLogics(List<Logic> logics) {
		this.logics = logics;
	}
	public List<MethodParam> getParams() {
		return params;
	}
	public void setParams(List<MethodParam> params) {
		this.params = params;
	}
	public String getSignatureJavaClass() {
		return signatureJavaClass;
	}
	public void setSignatureJavaClass(String signatureJavaClass) {
		this.signatureJavaClass = signatureJavaClass;
	}
	public Boolean getRegister() {
		return register;
	}
	public void setRegister(Boolean register) {
		this.register = register;
	}

	public void setParams(MethodParam... params){
		if(params!=null && params.length>0){
			for(int i=0;i<params.length;i++){
				if(params[i] != null){
					params[i].setIndex(i);
					this.params.add(params[i]);
				}
			}
		}
	}

	public String getRegistGroup() {
		return registGroup;
	}

	public void setRegistGroup(String registGroup) {
		this.registGroup = registGroup;
	}
	
}
